package com.learn.LR1Analysis;

import java.util.ArrayList;
import java.util.List;


public class SymbolStack {
    private List<Symbol> pool = new ArrayList<Symbol>();

    public boolean isEmpty() {
        return pool.isEmpty();
    }

    // 获取栈顶元素
    public Symbol getTopObjcet() {
        if (isEmpty()) {return null;}
        return pool.get(pool.size()-1);
    }
    //弹出栈操作
    public Symbol pop() {
        Symbol e=pool.get(pool.size()-1);
        pool.remove(pool.size()-1);
        return e;
    }
    //压入栈
    public void push(Symbol e) {
        pool.add(e);

    }
    // 获取当前栈大小
    public int getStatckSize() {
        return pool.size();
    }
    //输出当前栈
    public void output() {
        System.out.println(pool);
    }

    public String toString(){
        return pool.toString();
    }
}
